package com.tac.service.mes.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.dao.mes.TechnologyModelingDao;
import com.tac.pojo.mes.TechnologyModeling;
import com.tac.service.mes.TechnologyModelingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TechnologyModelingServiceImpl implements TechnologyModelingService {

    @Autowired
    private TechnologyModelingDao technologyModelingDao;


    @Override
    public Result<PageInfo<TechnologyModeling>>getList(Integer pageNum,Integer pageSize,String name) {
        PageHelper.startPage(pageNum,pageSize);
        List<TechnologyModeling> list = technologyModelingDao.getList(name);
        PageInfo<TechnologyModeling> technologyModelingPageInfo = new PageInfo<>(list);
        return Result.success(technologyModelingPageInfo);
    }

    @Override
    public Result save(TechnologyModeling technologyModeling) {
        Integer integer = technologyModelingDao.save(technologyModeling);
        if(integer<=0){
            return Result.error("添加工艺建模失败");
        }
        return Result.success(null);
    }

    @Override
    public Result remove(List<Integer> ids) {
        Integer integer = technologyModelingDao.remove(ids);
        if(integer<=0){
            return Result.error("删除工艺建模失败");
        }
        return Result.success(null);
    }

    @Override
    public Result update(TechnologyModeling technologyModeling) {
        Integer integer = technologyModelingDao.update(technologyModeling);
        if(integer<=0){
            return Result.error("修改工艺建模失败");
        }
        return Result.success(null);

    }
}
